<?php
class Admin_Form_Adpackage extends Zend_Form {
	
	const NAME = 'Tên gói cước';
	const DESCRIPTION = 'Mô tả';
	const STATE = 'Trạng thái';
	const PRICE = 'Giá';
	const SAVE = 'Save';
	const RESET = 'Reset';
	
	private function createIdElement() {
		$id = new Zend_Form_Element_Hidden('id');
		$id->addFilter('Int');
		return $id;
	}
	
	private function createNameElement() {
		$name = new Zend_Form_Element_Text('ten_goi');
		$name->setLabel(self::NAME)
			  ->setRequired(true)
			  ->addFilter('StringTrim')
			  ->addFilter('StripTags')
			  ->addValidator('NotEmpty', true)
			  ->setAttribs(array("maxlength" => "100"));
		return $name;
	}
	
	private function createPriceElement() {
		$price = new Zend_Form_Element_Text('gia');
		$price->setLabel(self::PRICE)
			  ->setRequired(true)
			  ->addFilter('StringTrim')
			  ->addValidator('NotEmpty', true)
			  ->addValidator('Digits')
			  ->setAttribs(array("maxlength" => "9"));
		return $price;
	}
	
	private function createDescriptionElement() {
		$description = new Zend_Form_Element_Textarea('mo_ta');
		$description->setLabel(self::DESCRIPTION)
				   	 ->addFilter('StringTrim')
				   	 ->addFilter('StripTags')
				   	 ->setAttribs(array("style" => "width: 400px; height: 250px;", "maxlength" => "255"));
		return $description;
	}
	
	private function createSubmitElement() {
		$submit = new Zend_Form_Element_Submit('submit');
        $submit->setAttrib('id', 'submitbutton')
        	   ->removeDecorator('DtDdWrapper')
        	   ->setLabel(self::SAVE)
        	   ->setAttrib("class", "btn btn-large btn-primary ");
       	return $submit;
	}
	
	private function createResetElement() {
		$reset = new Zend_Form_Element_Reset('reset'); 
		$reset->setAttrib('id', 'resetbutton')
			  ->removeDecorator('DtDdWrapper')
			  ->setLabel(self::RESET)
			  ->setAttrib("class", "btn btn-large");
		return $reset;	  
	}
	
    public function init() {
        $this->setName('goiquangcao');
        $this->setMethod('post');

		$id = $this->createIdElement();
		$name = $this->createNameElement();
		$price = $this->createPriceElement();
		$description = $this->createDescriptionElement();
		$submit = $this->createSubmitElement();
		$reset = $this->createResetElement();
        
        $this->addElements(array($id, $name, $price, $description , $submit, $reset));
        
		$this->addDisplayGroup(array('submit', 'reset'), 'buttons');
		$dg = $this->getDisplayGroup('buttons');
		$dg->removeDecorator('Fieldset');
		$dg->removeDecorator('HtmlTag');      
    }
	
}
?>